package cn.xinfei.xdecision.common.service.component.scriptrule;

import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.common.requestParam.AssemblyRuleCodeReq;
import cn.xinfei.xdecision.common.model.component.guiderule.vo.RuleVersionRespVo;
import cn.xinfei.xdecision.common.model.component.scriptrule.RuleMixExpressionCheck;
import cn.xinfei.xdecision.common.model.component.scriptrule.RuleMixExpressionCheckResult;
import cn.xinfei.xdecision.common.model.component.scriptrule.RuleScriptVersion;
import cn.xinfei.xdecision.common.utils.enums.enginex.ComponentVersionStatusEnum;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * (RuleScriptVersion)表服务接口
 */
public interface RuleScriptVersionService extends IService<RuleScriptVersion> {

    List<String> queryFieldEnByVersionId(Long versionId);

    List<Long> addVersionList(List<RuleScriptVersion> versionList);

    Long checkAndAddVersion(RuleScriptVersion version);

    Long addVersion(RuleScriptVersion version);

    boolean updateVersion(RuleScriptVersion version);

    /**
     * 锁定规则版本
     */
    void lock(Long versionId);

    // runner
    RuleScriptVersion queryById(Long id);

    RuleScriptVersion getVersionByVersionNo(String ruleCode, Long versionNo);
    List<RuleScriptVersion> getVersionByStatus(String ruleCode, int status);

    List<RuleScriptVersion> queryVersionListByRuleId(Long ruleId);

    /**
     * 通过规则code集合，查询版本集合
     *
     * @param ruleCodes 规则code
     * @param status    版本状态
     * @return {@link RuleScriptVersion 版本}
     * @see ComponentVersionStatusEnum
     */
    List<RuleScriptVersion> queryVersionByRuleCodes(List<String> ruleCodes, Integer status);

    List<String> queryFieldEnByVersionIds(List<Long> versionId);

    ResponseEntityDto<PageResult<List<RuleVersionRespVo>, RuleScriptVersion>> listByRuleCode(AssemblyRuleCodeReq req);

    /**
     * 脚本规则校验
     */
    List<RuleMixExpressionCheckResult> scriptRulecheck(RuleMixExpressionCheck mixExpressionCheck);
}
